package com.security.entity;

import com.security.util.SecurityCode;
import org.springframework.security.web.authentication.WebAuthenticationDetails;

import javax.servlet.http.HttpServletRequest;

public class CustomWebAuthenticationDetails extends WebAuthenticationDetails {

    private String imageCode;

    private String session_imageCode;

    private long session_imageTime;

    public CustomWebAuthenticationDetails(HttpServletRequest request) {
        super(request);
        this.imageCode = request.getParameter(SecurityCode.IMG_CODE.getCode());
        this.session_imageCode = (String)request.getSession().getAttribute(SecurityCode.IMG_CODE_SESSION.getCode());
        Long session_verifyTime = Long.parseLong(String.valueOf(request.getSession().getAttribute(SecurityCode.IMG_CODE_SESSION_TIME.getCode())));
        if(session_verifyTime == null) {
            this.session_imageTime= 0L;
        } else {
            this.session_imageTime= session_verifyTime;
        }
    }

    public String getImageCode(){
        return imageCode;
    }

    public String getSession_imageCode() {
        return session_imageCode;
    }

    public long getSession_imageTime() {
        return session_imageTime;
    }
}

